#pragma once

#include <functional>
#include <vector>
#include <map>
#include <string>
#include <boost/asio.hpp>

namespace libzq
{
	using func_stop_t = std::function<void()>;
	using func_run_t = std::function<void()>;

	class Core
	{
	public:
		static Core & instance();
		boost::asio::io_service& ioservice();
		void install_signals();
		void install_stop(func_stop_t cb);
		void run_until_stop(const std::string&& task_name, func_run_t task, func_stop_t cb, unsigned int interval);
	private:
		boost::asio::io_service _io_service;
		std::vector<func_stop_t> _stop_vec;
		std::map<std::string, bool> _task_map;
		void run();
		void stop();
	private:
		Core();
		Core(const Core&) = delete;
		Core& operator=(const Core&) = delete;
	};
}

#define CORE libzq::Core::instance()